home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / wg_lib / filefrm2.frm < prev    next >
Text File  |  1995-09-06  |  7KB  |  262 lines

  1. VERSION 2.00
  2. Begin Form FileFrm2 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Faster File I/O"
  5.    ClientHeight    =   3390
  6.    ClientLeft      =   1260
  7.    ClientTop       =   1710
  8.    ClientWidth     =   7170
  9.    Height          =   3795
  10.    Left            =   1200
  11.    LinkMode        =   1  'Source
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   3390
  14.    ScaleWidth      =   7170
  15.    Top             =   1365
  16.    Width           =   7290
  17.    Begin Frame Frame2 
  18.       BackColor       =   &H00C0C0C0&
  19.       Height          =   2415
  20.       Left            =   3750
  21.       TabIndex        =   7
  22.       Top             =   615
  23.       Width           =   3015
  24.       Begin CommandButton Command2 
  25.          Caption         =   "Execute"
  26.          Height          =   390
  27.          Left            =   930
  28.          TabIndex        =   10
  29.          Top             =   930
  30.          Width           =   810
  31.       End
  32.       Begin OptionButton VOpt 
  33.          BackColor       =   &H00C0C0C0&
  34.          Caption         =   "Read From File"
  35.          Height          =   285
  36.          Index           =   2
  37.          Left            =   420
  38.          TabIndex        =   9
  39.          Top             =   525
  40.          Visible         =   0   'False
  41.          Width           =   1980
  42.       End
  43.       Begin OptionButton VOpt 
  44.          BackColor       =   &H00C0C0C0&
  45.          Caption         =   "Write To File"
  46.          Height          =   255
  47.          Index           =   1
  48.          Left            =   420
  49.          TabIndex        =   8
  50.          Top             =   195
  51.          Value           =   -1  'True
  52.          Width           =   2025
  53.       End
  54.       Begin Label VRes 
  55.          BackColor       =   &H00FFFFFF&
  56.          Height          =   270
  57.          Left            =   150
  58.          TabIndex        =   12
  59.          Top             =   1920
  60.          Width           =   2700
  61.       End
  62.       Begin Label VMsg 
  63.          Height          =   255
  64.          Left            =   165
  65.          TabIndex        =   11
  66.          Top             =   1515
  67.          Width           =   2685
  68.       End
  69.    End
  70.    Begin Frame Frame1 
  71.       BackColor       =   &H00C0C0C0&
  72.       Height          =   2415
  73.       Left            =   330
  74.       TabIndex        =   0
  75.       Top             =   615
  76.       Width           =   3015
  77.       Begin CommandButton Command1 
  78.          Caption         =   "Execute"
  79.          Height          =   375
  80.          Left            =   1080
  81.          TabIndex        =   2
  82.          Top             =   960
  83.          Width           =   855
  84.       End
  85.       Begin OptionButton IOpt 
  86.          BackColor       =   &H00C0C0C0&
  87.          Caption         =   "Read From File"
  88.          Height          =   255
  89.          Index           =   2
  90.          Left            =   360
  91.          TabIndex        =   5
  92.          Top             =   600
  93.          Visible         =   0   'False
  94.          Width           =   2295
  95.       End
  96.       Begin OptionButton IOpt 
  97.          BackColor       =   &H00C0C0C0&
  98.          Caption         =   "Write To File"
  99.          Height          =   255
  100.          Index           =   1
  101.          Left            =   360
  102.          TabIndex        =   4
  103.          Top             =   225
  104.          Value           =   -1  'True
  105.          Width           =   2175
  106.       End
  107.       Begin Label IRes 
  108.          BackColor       =   &H00FFFFFF&
  109.          ForeColor       =   &H00000000&
  110.          Height          =   255
  111.          Left            =   225
  112.          TabIndex        =   6
  113.          Top             =   1950
  114.          Width           =   2550
  115.       End
  116.       Begin Label IMSg 
  117.          BackColor       =   &H00FFFFFF&
  118.          Height          =   240
  119.          Left            =   225
  120.          TabIndex        =   3
  121.          Top             =   1500
  122.          Width           =   2535
  123.       End
  124.    End
  125.    Begin Label Label6 
  126.       BackColor       =   &H00C0C0C0&
  127.       Caption         =   "Normal VB "
  128.       Height          =   210
  129.       Left            =   3765
  130.       TabIndex        =   13
  131.       Top             =   375
  132.       Width           =   1830
  133.    End
  134.    Begin Label Label1 
  135.       BackColor       =   &H00C0C0C0&
  136.       Caption         =   "InfoSoft I/O"
  137.       Height          =   255
  138.       Left            =   330
  139.       TabIndex        =   1
  140.       Top             =   375
  141.       Width           =   1335
  142.    End
  143. End
  144. DefInt A-Z
  145.  
  146. Dim IFil As String
  147. Dim VFil As String
  148.  
  149. Sub Command1_Click ()
  150.     IMsg.Caption = "Creating random file"
  151.     IRes.Caption = ""
  152.     IRes.Refresh
  153.  
  154.     quan = 3500
  155.     ReDim Test(1 To quan) As TStruct
  156.  
  157.     If IOpt(1).value Then
  158.         For x = 1 To quan
  159.             Test(x).i = x
  160.             Test(x).l = x
  161.             Test(x).s = String$(6, "!")
  162.         Next x
  163.     End If
  164.  
  165.     IMsg.Caption = "Memory structure done. Starting timer"
  166.     IMsg.Refresh
  167.  
  168.     IFil$ = "ITest.fil"
  169.  
  170.     s! = Timer
  171.  
  172.     If IOpt(1).value Then
  173.         IMsg.Caption = "Outputting to file"
  174.         errc = FCreat(IFil$, Fhandle)
  175.     Else
  176.         IMsg.Caption = "Reading from file"
  177.         errc = FOpen(IFil$, Fhandle)
  178.     End If
  179.  
  180.     IMsg.Refresh
  181.     siz = Len(Test(1))
  182.     If IOpt(1).value Then
  183.         errc = FRecPutA(Fhandle, quan, siz, Test(1))
  184.         IOpt(2).Visible = 1
  185.     Else
  186.         errc = FRecGetA(Fhandle, quan, siz, Test(1))
  187.     End If
  188.     el! = Timer - s!
  189.  
  190.     errc = FClose(Fhandle)
  191.     IRes.Caption = "Our I/O ops took " + Format$(el!) + " secs"
  192.     IMsg.Caption = "Done"
  193.  
  194. End Sub
  195.  
  196. Sub Command2_Click ()
  197.     VMsg.Caption = "Creating random file"
  198.     VRes.Caption = ""
  199.     VRes.Refresh
  200.  
  201.     quan = 3500
  202.     ReDim Test(1 To quan) As TStruct
  203.  
  204.     If VOpt(1).value Then
  205.         For x = 1 To quan
  206.             Test(x).i = x
  207.             Test(x).l = x
  208.             Test(x).s = String$(6, "!")
  209.         Next x
  210.     End If
  211.  
  212.     VMsg.Caption = "Memory structure done. Starting timer"
  213.     VMsg.Refresh
  214.  
  215.     VFil$ = "VTest.fil"
  216.  
  217.     s! = Timer
  218.  
  219.     If VOpt(1).value Then
  220.         VMsg.Caption = "Outputting to file"
  221.         fh = FreeFile
  222.         Open VFil$ For Random As #fh Len = Len(Test(1))
  223.     Else
  224.         VMsg.Caption = "Reading from file"
  225.         fh = FreeFile
  226.         Open VFil$ For Random As #fh Len = Len(Test(1))
  227.     End If
  228.  
  229.     VMsg.Refresh
  230.     siz = Len(Test(1))
  231.     If VOpt(1).value Then
  232.         For x = 1 To quan
  233.             Put #fh, x, Test(x)
  234.         Next x
  235.         VOpt(2).Visible = 1
  236.     Else
  237.         For x = 1 To quan
  238.             Get #fh, x, Test(x)
  239.         Next x
  240.     End If
  241.     el! = Timer - s!
  242.  
  243.     Close #fh
  244.     VRes.Caption = "VB I/O ops took " + Str$(el!) + " secs"
  245.     VMsg.Caption = "Done"
  246.  
  247. End Sub
  248.  
  249. Sub Form_Paint ()
  250.      ConvexFrm FileFrm2, 5
  251.      ConcaveCtl IMsg, 3
  252.      ConcaveCtl IRes, 3
  253.      ConcaveCtl VMsg, 3
  254.      ConcaveCtl VRes, 3
  255. End Sub
  256.  
  257. Sub Form_Unload (Cancel As Integer)
  258.      If Fexists(IFil$) Then Kill IFil$
  259.      If Fexists(VFil$) Then Kill VFil$
  260. End Sub
  261.  
  262.